
import { Component } from "react";
import type { ReactNode } from 'react'

interface iProps {
    title: string
}

class Header extends Component {

    props = {
        title: '默认值'
    }

    constructor(props: iProps) {
        super(props)
        this.props = props
    }

    render(): ReactNode {
        return <header>
            <h1>头部组件 --- {this.props.title}</h1>
        </header>
    }
}

export default class App extends Component {

    state = {
        title: '辣条'
    }


    render(): ReactNode {
        return <>
            <div>
                <h1>父组件 -- {this.state.title}</h1>
                <hr />
                {/* 2. 将接收方法传递到子组件 */}
                <Header title={this.state.title}></Header>

            </div>
        </>
    }
}